package 蓝桥杯.算法板子.数学;

import java.io.*;
import java.math.BigInteger;
import java.util.StringTokenizer;

/**
 * @Title: 试除法判定质数
 * @Author 贾金博
 * @Package 蓝桥杯.算法板子.数学
 * @Date 2024/4/12 18:52
 * @description:
 */
public class 试除法判定质数 {
    public static FastReader sc = new FastReader();
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) {
        int n = sc.nextInt();
        while(n -- != 0 ) {
            Long x = sc.nextLong();
            if(isPrime(x, 100)) { // 里面这个参数设置的越小 越快但是越不准确
                out.print("Yes\n");
            } else {
                out.print("No\n");
            }
        }
        //注意刷新流
        out.flush();
    }

    static boolean isPrime(long n, int certainty) {
        BigInteger bigInteger = BigInteger.valueOf(n);
        return bigInteger.isProbablePrime(certainty);
    }
}

//快读的模板
class FastReader{
    StringTokenizer st;
    BufferedReader br;
    public FastReader(){
        br=new BufferedReader(new InputStreamReader(System.in));
    }

    String next(){
        while (st==null||!st.hasMoreElements()){
            try {
                st=new StringTokenizer(br.readLine());
            }catch (IOException e){
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}
